package com.lagou.course.controller;


import com.alibaba.dubbo.config.annotation.Reference;
import com.lagou.course.CourseService;
import com.lagou.entity.Course;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("course")
public class CourseController {

    //远程注入
    @Reference
    private CourseService courseService;

    @GetMapping("getAllCourse")
    public List<Course> getAllCourse() {

        List<Course> courseList = courseService.getAllCourse ();
        return courseList;
    }

    @GetMapping("getCourseByUserId/{userid}")
    public List<Course> getCourseByUserId(@PathVariable("userid") String userid) {
        List<Course> courseList = courseService.getCourseByUserId (userid);
        return courseList;
    }

    @GetMapping("getCourseById/{courseid}")
    public Course getCourseById(@PathVariable("courseid") String courseid) {
        Course course = courseService.getCourseById (courseid);
        return course;
    }
}
